package com.example.restful01.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.restful01.mapper.BookMapper;
import com.example.restful01.mapper.BorrowRecordsMapper;
import com.example.restful01.mapper.ReservationMapper;
import com.example.restful01.model.Book;
import com.example.restful01.model.BorrowRecords;
import com.example.restful01.model.Reservation;
import com.example.restful01.service.BookService;
import com.example.restful01.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReservationServiceImpl extends ServiceImpl<ReservationMapper, Reservation> implements ReservationService {

    @Autowired
    private ReservationMapper reservationMapper;
    @Override
    public boolean deleteReserve(BorrowRecords borrowRecords) {
        return reservationMapper.deleteBorrows(
                borrowRecords.getReaderId(),
                borrowRecords.getBookId()
        ) > 0;
    }

    @Override
    public boolean addReserve(Reservation reservation) {
        return reservationMapper.addReserve(reservation)>0;
    }

    @Override
    public List<Reservation> initReserve(Integer readerId) {
        return reservationMapper.initReserve(readerId);
    }

}
